Quickstart Ionic
This guide will help you to implement the Group Link SDK on your application written for the Ionic framework.
Requirements
- Required software:
- IDE (VSCode or Android Studio)
- Capacitor environment setup
Step 1 - Getting the SDK
To get our Ionic plugin, run the following command in your project's root directory from your terminal at the root of your Ionic project.
npm install @grouplinknetwork/ionic-grouplink-sdk
npx cap sync
Step 2 - Importing the SDK
First, import the necessary dependencies to your application init file.
import * as Grouplink from "@grouplinknetwork/group-link-ionic-plugin";
Step 3 - Setting up the platform specifics
iOS Specifics
To ensure proper functionality of the plugin on iOS devices, you need to insert specific strings into your application's info.plist file. These strings relate to permissions and app capabilities. You can find detailed instructions on how to insert them by referring to the iOS Required Permissions documentation.
Android Specifics
Add the JitPack repository to your build file. Add it to your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 4 - Calling the SDK functions
Now that you have properly installed and imported the Ionic plugin, simply call the SDK functions in your init file. We recommend initializing the Group Link SDK at the beginning of your application on your application constructor() function:
constructor() {
Grouplink.GLStart(
"GROUP_LINK_TOKEN"
);
}
Asking for Bluetooth and Location permissions
If your app does not request Bluetooth, Location, or Notification permissions, the Group Link SDK can handle this process for you. However, it is still necessary to ask the user for these permissions for the SDK to function correctly. You can initiate this process by calling the Grouplink.GLRequestPermissions() function.
// Asking for the Bluetooth, location, and notification permissions of the user;
Grouplink.GLRequestPermissions();
Getting the user given userID
The userID
is an optional String identifier that is unique to each user within the Group Link network. By utilizing this ID, you can identify when a particular user approaches one of our devices.
// Asking for the userId of the user;
Grouplink.GLGetUserID().then((id) => {
this.userId = id;
});
Step 5 - Setting up the Push Notification capability
To utilize our custom notifications in the dashboard, you need to call the Grouplink.GLSetNotificationToken()
function. This function expects a String parameter, which represents the user's notification token. On iOS, this token is provided by APNS (Apple Push Notification Service), while on Android, it is obtained through Firebase Cloud Messaging.
Grouplink.GLSetNotificationToken("NOTIFICATION_TOKEN");
Now with Group Link SDK in your application, you can utilize its features seamlessly.